home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 141_01 / logon.c < prev    next >
Text File  |  1985-03-09  |  14KB  |  694 lines

  1. /* LOGON PROGRAM IN BDS C 
  2.    
  3.    r p sarna -- 19 jan 1984
  4.  
  5.    dirigo data support systems 
  6.    p o box 259
  7.    auburn, me 04210
  8.  
  9. */
  10.  
  11. #include <bdscio.h>
  12.  
  13. /* Make logon id's in memory: */
  14. char id0[11];
  15. char id1[11];
  16. char id2[11];
  17. char id3[11];
  18. char id4[11];
  19. char id5[11];
  20. char id6[11];
  21. char id7[11];
  22. char id8[11];
  23. char id9[11];
  24. char id10[11];
  25. char id11[11];
  26. char id12[11];
  27. char id13[11];
  28. char id14[11];
  29. char id15[11];
  30.  
  31. /* Make passwords in memory: */
  32. char pw0[11];
  33. char pw1[11];
  34. char pw2[11];
  35. char pw3[11];
  36. char pw4[11];
  37. char pw5[11];
  38. char pw6[11];
  39. char pw7[11];
  40. char pw8[11];
  41. char pw9[11];
  42. char pw10[11];
  43. char pw11[11];
  44. char pw12[11];
  45. char pw13[11];
  46. char pw14[11];
  47. char pw15[11];
  48.  
  49. int ptr;        /* pointer (value of)  proper user number */
  50. int unum;        /* user number */      
  51. char idin[11];        /* logon id (answer from person logging on) */ 
  52. char pwin[11];        /* password (answer from person logging on) */ 
  53. char badfile;        /* flag -- can't write out 'secret' file */
  54.  
  55. main() 
  56. {
  57.     getstuff();    /* read 'secret' file that has legal passwords */
  58.  
  59. nogood:    clear();
  60.     badfile = NO;
  61.     idin[0] = '\0';
  62.     printf("logon identification? ");     /* ask "Who's there?" */
  63.     getid();
  64.     ptr = -1;
  65.     if (strcmp(idin, id0) == 0) ptr = 0;    /* see if we know them */
  66.     else if (strcmp(idin, id1) == 0) ptr = 1;
  67.     else if (strcmp(idin, id2) == 0) ptr = 2;
  68.     else if (strcmp(idin, id3) == 0) ptr = 3;
  69.     else if (strcmp(idin, id4) == 0) ptr = 4;
  70.     else if (strcmp(idin, id5) == 0) ptr = 5;
  71.     else if (strcmp(idin, id6) == 0) ptr = 6;
  72.     else if (strcmp(idin, id7) == 0) ptr = 7;
  73.     else if (strcmp(idin, id8) == 0) ptr = 8;
  74.     else if (strcmp(idin, id9) == 0) ptr = 9;
  75.     else if (strcmp(idin, id10) == 0) ptr = 10;
  76.     else if (strcmp(idin, id11) == 0) ptr = 11;
  77.     else if (strcmp(idin, id12) == 0) ptr = 12;
  78.     else if (strcmp(idin, id13) == 0) ptr = 13;
  79.     else if (strcmp(idin, id14) == 0) ptr = 14;
  80.     else if (strcmp(idin, id15) == 0) ptr = 15;
  81.  
  82.     if (ptr < 0) goto nogood;    /* we don't know them - ask again */
  83.  
  84.     pwin[0] = '\0';            /* clean out password string */
  85.  
  86.     switch (ptr) {
  87.         case 0: {
  88.             printf("\n\npassword? ");    /* ask password */
  89.             getpw();
  90.             if (strcmp(pwin, pw0) != 0) goto nogood;
  91.             usrset( 0); 
  92.  
  93. doover:            printf("\n\nchange user number = ? (16 to save & end) ");
  94.             scanf("%d", &unum);
  95.  
  96.             switch (unum) {
  97.  
  98.                 case 0: {
  99. /* if logged in to 0; change? */    printf("\npresent logon id: '%s'", id0);
  100.                     printf("\npresent password: '%s'", pw0);
  101.                     printf("\n\nnew logon identification ? ");
  102.                     scanf("%s", idin);
  103.  
  104.                     strcpy(id0, idin);
  105.  
  106.                     printf("\nnew password = ? ");
  107.                     scanf("%s", pwin);
  108.  
  109.                     strcpy(pw0, pwin);
  110.                     goto doover;
  111.                     }
  112.  
  113.  
  114.  
  115.                 case 1: {
  116.                     printf("\npresent logon id: '%s'", id1);
  117.                     printf("\npresent password: '%s'", pw1);
  118.                     printf("\n\nnew logon identification ? ");
  119.                     scanf("%s", idin);
  120.  
  121.                     strcpy(id1, idin);
  122.  
  123.                     printf("\nnew password = ? ");
  124.                     scanf("%s", pwin);
  125.  
  126.                     strcpy(pw1, pwin);
  127.  
  128.                     goto doover;
  129.                     }
  130.  
  131.  
  132.  
  133.                 case 2: {
  134.                     printf("\npresent logon id: '%s'", id2);
  135.                     printf("\npresent password: '%s'", pw2);
  136.                     printf("\n\nnew logon identification ? ");
  137.                     scanf("%s", idin);
  138.  
  139.                     strcpy(id2, idin);
  140.  
  141.                     printf("\nnew password = ? ");
  142.                     scanf("%s", pwin);
  143.  
  144.                     strcpy(pw2, pwin);
  145.  
  146.                     goto doover;
  147.                     }
  148.  
  149.  
  150.                 case 3: {
  151.                     printf("\npresent logon id: '%s'", id3);
  152.                     printf("\npresent password: '%s'", pw3);
  153.                     printf("\n\nnew logon identification ? ");
  154.                     scanf("%s", idin);
  155.  
  156.                     strcpy(id3, idin);
  157.  
  158.                     printf("\nnew password = ? ");
  159.                     scanf("%s", pwin);
  160.  
  161.                     strcpy(pw3, pwin);
  162.  
  163.                     goto doover;
  164.                     }
  165.  
  166.  
  167.  
  168.                 case 4: {
  169.                     printf("\npresent logon id: '%s'", id4);
  170.                     printf("\npresent password: '%s'", pw4);
  171.                     printf("\n\nnew logon identification ? ");
  172.                     scanf("%s", idin);
  173.  
  174.                     strcpy(id4, idin);
  175.  
  176.                     printf("\nnew password = ? ");
  177.                     scanf("%s", pwin);
  178.  
  179.                     strcpy(pw4, pwin);
  180.  
  181.                     goto doover;
  182.                     }
  183.  
  184.  
  185.                 case 5: {
  186.                     printf("\npresent logon id: '%s'", id5);
  187.                     printf("\npresent password: '%s'", pw5);
  188.                     printf("\n\nnew logon identification ? ");
  189.                     scanf("%s", idin);
  190.  
  191.                     strcpy(id5, idin);
  192.  
  193.                     printf("\nnew password = ? ");
  194.                     scanf("%s", pwin);
  195.  
  196.                     strcpy(pw5, pwin);
  197.  
  198.                     goto doover;
  199.                     }
  200.  
  201.  
  202.  
  203.                 case 6: {
  204.                     printf("\npresent logon id: '%s'", id6);
  205.                     printf("\npresent password: '%s'", pw6);
  206.                     printf("\n\nnew logon identification ? ");
  207.                     scanf("%s", idin);
  208.  
  209.                     strcpy(id6, idin);
  210.  
  211.                     printf("\nnew password = ? ");
  212.                     scanf("%s", pwin);
  213.  
  214.                     strcpy(pw6, pwin);
  215.  
  216.                     goto doover;
  217.                     }
  218.  
  219.  
  220.                 case 7: {
  221.                     printf("\npresent logon id: '%s'", id7);
  222.                     printf("\npresent password: '%s'", pw7);
  223.                     printf("\n\nnew logon identification ? ");
  224.                     scanf("%s", idin);
  225.  
  226.                     strcpy(id7, idin);
  227.  
  228.                     printf("\nnew password = ? ");
  229.                     scanf("%s", pwin);
  230.  
  231.                     strcpy(pw7, pwin);
  232.  
  233.                     goto doover;
  234.                     }
  235.  
  236.  
  237.  
  238.                 case 8: {
  239.                     printf("\npresent logon id: '%s'", id8);
  240.                     printf("\npresent password: '%s'", pw8);
  241.                     printf("\n\nnew logon identification ? ");
  242.                     scanf("%s", idin);
  243.  
  244.                     strcpy(id8, idin);
  245.  
  246.                     printf("\nnew password = ? ");
  247.                     scanf("%s", pwin);
  248.  
  249.                     strcpy(pw8, pwin);
  250.  
  251.                     goto doover;
  252.                     }
  253.  
  254.  
  255.                 case 9: {
  256.                     printf("\npresent logon id: '%s'", id9);
  257.                     printf("\npresent password: '%s'", pw9);
  258.                     printf("\n\nnew logon identification ? ");
  259.                     scanf("%s", idin);
  260.  
  261.                     strcpy(id9, idin);
  262.  
  263.                     printf("\nnew password = ? ");
  264.                     scanf("%s", pwin);
  265.  
  266.                     strcpy(pw9, pwin);
  267.  
  268.                     goto doover;
  269.                     }
  270.  
  271.  
  272.  
  273.                 case 10: {
  274.                     printf("\npresent logon id: '%s'", id10);
  275.                     printf("\npresent password: '%s'", pw10);
  276.                     printf("\n\nnew logon identification ? ");
  277.                     scanf("%s", idin);
  278.  
  279.                     strcpy(id10, idin);
  280.  
  281.                     printf("\nnew password = ? ");
  282.                     scanf("%s", pwin);
  283.  
  284.                     strcpy(pw10, pwin);
  285.  
  286.                     goto doover;
  287.                     }
  288.  
  289.  
  290.                 case 11: {
  291.                     printf("\npresent logon id: '%s'", id11);
  292.                     printf("\npresent password: '%s'", pw11);
  293.                     printf("\n\nnew logon identification ? ");
  294.                     scanf("%s", idin);
  295.  
  296.                     strcpy(id11, idin);
  297.  
  298.                     printf("\nnew password = ? ");
  299.                     scanf("%s", pwin);
  300.  
  301.                     strcpy(pw11, pwin);
  302.  
  303.                     goto doover;
  304.                     }
  305.  
  306.  
  307.  
  308.                 case 12: {
  309.                     printf("\npresent logon id: '%s'", id12);
  310.                     printf("\npresent password: '%s'", pw12);
  311.                     printf("\n\nnew logon identification ? ");
  312.                     scanf("%s", idin);
  313.  
  314.                     strcpy(id12, idin);
  315.  
  316.                     printf("\nnew password = ? ");
  317.                     scanf("%s", pwin);
  318.  
  319.                     strcpy(pw12, pwin);
  320.  
  321.                     goto doover;
  322.                     }
  323.  
  324.  
  325.                 case 13: {
  326.                     printf("\npresent logon id: '%s'", id13);
  327.                     printf("\npresent password: '%s'", pw13);
  328.                     printf("\n\nnew logon identification ? ");
  329.                     scanf("%s", idin);
  330.  
  331.                     strcpy(id13, idin);
  332.  
  333.                     printf("\nnew password = ? ");
  334.                     scanf("%s", pwin);
  335.  
  336.                     strcpy(pw13, pwin);
  337.  
  338.                     goto doover;
  339.                     }
  340.  
  341.  
  342.  
  343.                 case 14: {
  344.                     printf("\npresent logon id: '%s'", id14);
  345.                     printf("\npresent password: '%s'", pw14);
  346.                     printf("\n\nnew logon identification ? ");
  347.                     scanf("%s", idin);
  348.  
  349.                     strcpy(id14, idin);
  350.  
  351.                     printf("\nnew password = ? ");
  352.                     scanf("%s", pwin);
  353.  
  354.                     strcpy(pw14, pwin);
  355.  
  356.                     goto doover;
  357.                     }
  358.  
  359.  
  360.                 case 15: {
  361.                     printf("\npresent logon id: '%s'", id15);
  362.                     printf("\npresent password: '%s'", pw15);
  363.                     printf("\n\nnew logon identification ? ");
  364.                     scanf("%s", idin);
  365.  
  366.                     strcpy(id15, idin);
  367.  
  368.                     printf("\nnew password = ? ");
  369.                     scanf("%s", pwin);
  370.  
  371.                     strcpy(pw15, pwin);
  372.  
  373.                     goto doover;
  374.                     }
  375.  
  376.                 case 16: {      
  377. /* dump out file: */            savestuff();
  378.                     break;
  379.                     }
  380.  
  381.                 default: goto nogood;
  382.                 }
  383.  
  384.             if (badfile == YES) goto nogood;
  385.             break;
  386.             }
  387.  
  388.         case 1: {
  389. /* for each user:   */    printf("\n\npassword? ");
  390. /* get his password */    getpw();
  391. /* if wrong, abort  */    if (strcmp(pwin, pw1) != 0) goto nogood;
  392. /* if OK set user # */    usrset( 1); 
  393. /* all done         */    break;
  394.             }
  395.  
  396.         case